--晚霞依旧
local wanxiayijiu = fk.CreateSkill {
    name = "mcdh_wanxiayijiu",
    tags = {Skill.Lord}
}

wanxiayijiu:addEffect(fk.AfterCardsMove,{
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill(wanxiayijiu.name) and player:usedSkillTimes(wanxiayijiu.name,Player.HistoryRound) == 0 then
            for _, move in ipairs(data) do
        if move.from == player and move.to and move.to ~= player and not move.to.dead and move.toArea == Card.PlayerHand then
          for _, info in ipairs(move.moveInfo) do
              return true
          end
        end
      end
        end
    end,
    on_trigger=function (self, event, target, player, data)
        local room = player.room
        local targets = {}
        for _, move in ipairs(data) do
            if move.from == player and move.to and move.to ~= player and not move.to.dead and move.toArea == Card.PlayerHand then
            table.insertIfNeed(targets,move.to)
            end
        end
        room:sortByAction(targets)
        for _, p in pairs(targets) do
             if not player:hasSkill(wanxiayijiu.name) or player:usedSkillTimes(wanxiayijiu.name,Player.HistoryRound) ~= 0 then break end
             if not p.dead then
                event:setCostData(self,p)
                self:doCost(event, target, player, data)
             end
        end
    end,
    on_cost=function (self, event, target, player, data)
        local room = player.room
        local p =event:getCostData(self)
        return room:askToSkillInvoke(player,{prompt="#wanxiayijiu:"..p.id,skill_name=wanxiayijiu.name})
    end,
    on_use=function (self, event, target, player, data)
        local room = player.room
        local p =event:getCostData(self)
        local choices ={"#wanxiayijiu1","#wanxiayijiu2"}
        local choice =room:askToChoice(p,{choices=choices,cancelable=false,prompt="#wanxiayijiu-chhoice"})
        if choice == "#wanxiayijiu1" then
            room:setPlayerMark(p,"@@wanxiayijiu_use-turn",1)
            if p:isWounded() then
                room:recover({
                    who = p,
                    num = 1
                })
            end
        else
            room:setPlayerMark(p,"@@wanxiayijiu_target-turn",1)
        end
    end
})

wanxiayijiu:addEffect("prohibit",{
    prohibit_use=function (self, player, card)
        return player:getMark("@@wanxiayijiu_use-turn") ~= 0
    end,
    is_prohibited = function(self, from, to, card)
            return to:getMark("@@wanxiayijiu_target-turn") ~= 0
    end,

})

Fk:loadTranslationTable {
    ["mcdh_wanxiayijiu"] = "晚霞依旧",
    [":mcdh_wanxiayijiu"] = "主公技，每轮限一次，其他角色获得你的牌后，你可以令其选择一项：1.本回合不能使用牌，然后回复1点体力；2.本回合不能成为牌的目标。",
    ["#wanxiayijiu"] = "晚霞依旧: 令 %src 选择一项 ",
    ["#wanxiayijiu1"] = "1.本回合不能使用牌，然后回复1点体力",
    ["#wanxiayijiu2"] = "2.本回合不能成为牌的目标。",
    ["@@wanxiayijiu_use-turn"] = "晚霞依旧:使用",
    ["@@wanxiayijiu_target-turn"] = "晚霞依旧:目标"

}

return wanxiayijiu